home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / include / a.out.h next >
C/C++ Source or Header  |  1990-07-15  |  4KB  |  112 lines

  1. /* The <a.out> header file describes the format of executable files. */
  2. /* This version is intended for the Atari ST */
  3.  
  4. #ifndef _AOUT_H
  5. #define _AOUT_H
  6.  
  7. struct    exec {            /* a.out header */
  8.     unsigned char    a_cpu;        /* cpu id */
  9.     unsigned char    a_flags;    /* flags, see below */
  10.     unsigned char    a_magic[2];    /* magic number */
  11.     unsigned short    a_version;    /* version stamp */    
  12.                 /* not used */
  13.     unsigned char    a_unused;    /* reserved for future use */
  14.     unsigned char    a_hdrlen;    /* length of header */
  15.     long        a_text;        /* size of text segement in bytes */
  16.     long        a_data;        /* size of data segment in bytes */
  17.     long        a_bss;        /* size of bss segment in bytes */
  18.     long        a_no_entry;    /* in fact: entry point, a_entry */
  19.     long        a_total;    /* total memory allocated */
  20.     long        a_syms;        /* size of symbol table */
  21.                 /* SHORT FORM ENDS HERE */
  22.     long        a_trsize;    /* text relocation size */
  23.     long        a_drsize;    /* data relocation size */
  24.     long        a_tbase;    /* text relocation base */
  25.     long        a_dbase;    /* data relocation base */
  26. };
  27.  
  28. #define A_MAGIC0    (unsigned char) 0x03
  29. #define A_MAGIC1    (unsigned char) 0x01
  30. #define BADMAG(X)    ((X).a_magic[0] != A_MAGIC0 ||\
  31.              (X).a_magic[1] != A_MAGIC1)
  32.  
  33. /* CPU Id of TARGET machine */
  34.     /* byte order coded in low order two bits */
  35. #define A_NONE    0x00    /* unknown */
  36. #define A_I8086    0x04    /* intel i8086/8088 */
  37. #define A_M68K    0x0B    /* motorola m68000 */
  38. #define A_NS16K    0x0C    /* national semiconductor 16032 */
  39. #define A_I80386    0x10    /* intel i80386 */
  40.  
  41. #define A_BLR(cputype)    ((cputype&0x01)!=0) /* TRUE if bytes left-to-right */
  42. #define A_WLR(cputype)    ((cputype&0x02)!=0) /* TRUE if words left-to-right */
  43.  
  44. /* flags: */
  45. #define A_EXEC    0x10    /* executable */
  46. #define A_SEP    0x20    /* separate I/D */
  47. #define A_PURE    0x40    /* pure text */        /* not used */
  48. #define A_TOVLY    0x80    /* text overlay */    /* not used */
  49.  
  50. /* offsets of various things: */
  51. #define A_MINHDR    32
  52. #define    A_TEXTPOS(X)    ((long)(X).a_hdrlen)
  53. #define A_DATAPOS(X)    (A_TEXTPOS(X) + (X).a_text)
  54. #define    A_HASRELS(X)    ((X).a_hdrlen > (unsigned char) A_MINHDR)
  55. #define A_HASEXT(X)    ((X).a_hdrlen > (unsigned char) (A_MINHDR +  8))
  56. #define A_HASLNS(X)    ((X).a_hdrlen > (unsigned char) (A_MINHDR + 16))
  57. #define A_HASTOFF(X)    ((X).a_hdrlen > (unsigned char) (A_MINHDR + 24))
  58. #define A_TRELPOS(X)    (A_DATAPOS(X) + (X).a_data)
  59. #define A_DRELPOS(X)    (A_TRELPOS(X) + (X).a_trsize)
  60. #define A_SYMPOS(X)    (A_TRELPOS(X) + (A_HASRELS(X) ? \
  61.                 ((X).a_trsize + (X).a_drsize) : 0))
  62.  
  63. struct reloc {
  64.     long        r_vaddr;    /* virtual address of reference */
  65.     unsigned short    r_symndx;    /* internal segnum or extern symbol num */
  66.     unsigned short    r_type;        /* relocation type */
  67. };
  68.  
  69. /* r_tyep values: */
  70. #define R_ABBS        0
  71. #define R_RELLBYTE    2
  72. #define R_PCRBYTE    3
  73. #define R_RELWORD    4
  74. #define R_PCRWORD    5
  75. #define R_RELLONG    6
  76. #define R_PCRLONG    7
  77. #define R_REL3BYTE    8
  78. #define R_KBRANCHE    9
  79.  
  80. /* r_symndx for internal segments */
  81. #define S_ABS        ((unsigned short)-1)
  82. #define S_TEXT        ((unsigned short)-2)
  83. #define S_DATA        ((unsigned short)-3)
  84. #define S_BSS        ((unsigned short)-4)
  85.  
  86. struct nlist {            /* symbol table entry */
  87.     char         n_name[8];    /* symbol name */
  88.     long         n_value;    /* value */
  89.     unsigned char    n_sclass;    /* storage class */
  90.     unsigned char    n_numaux;    /* number of auxiliary entries */
  91.                         /* not used */
  92.     unsigned short    n_type;        /* language base and derived type */
  93.                         /* not used */
  94. };
  95.  
  96. /* low bits of storage class (section) */
  97. #define    N_SECT          07    /* section mask */
  98. #define N_UNDF          00    /* undefined */
  99. #define N_ABS          01    /* absolute */
  100. #define N_TEXT          02    /* text */
  101. #define N_DATA          03    /* data */
  102. #define    N_BSS          04    /* bss */
  103. #define N_COMM          05    /* (common) */
  104.  
  105. /* high bits of storage class */
  106. #define N_CLASS        0370    /* storage class mask */
  107. #define C_NULL
  108. #define C_EXT        0020    /* external symbol */
  109. #define C_STAT        0030    /* static */
  110.  
  111. #endif /* _AOUT_H */
  112.